import React, {
  Component
} from 'react';
import {
  View,
  Text,
  StyleSheet,
  TouchableHighlight,
  NativeModules,
  ToastAndroid,
} from 'react-native';
import {
  Provider,
} from 'react-redux';

import Day1 from './day1';
// import Day2 from './day2';
import OnePage from './chucun';

class fdxApp extends Component {
  render() {
    return (
      <OnePage/>
    );
  }
}

class CustomButton extends Component {
  render() {
    return (
      <TouchableHighlight
        style={styles.button}
           underlayColor="#a5a5a5"
        onPress={this.props.onPress}>
        <Text style={styles.buttonText}>{this.props.text}</Text>
      </TouchableHighlight>
    );
  }
}

/**
 * 这里是测试二维码模块
 */
class flipped2 extends Component {
  render() {
    return (
      <View>
        <Text style={styles.welcome}>
          自定义弹出Toast消息
        </Text>
        <CustomButton
          text="点击弹出Toast消息"
              onPress={()=>NativeModules.ToastCustomAndroid.startActivityFromJS("com.flipped.IntentActivity","我是从JS传过来的参数信息.456")}
              // onPress={()=>NativeModules.ToastCustomAndroid.measureLayout((msg) => {console.log(msg)},(a,b,c,d) =>{console.log(a,b,c,d);alert(a)})}
        />
        <CustomButton
          text="点击跳转到Activity界面,并且等待数据返回..."
          onPress={() => NativeModules.ToastCustomAndroid.startActivityFromJSGetResult("com.flipped.IntentActivity",200,(msg) => {
                    ToastAndroid.show('JS界面:从Activity中传输过来的数据为:'+msg,ToastAndroid.SHORT);
                  },
                   (result) => {
                    ToastAndroid.show('JS界面:错误信息为:'+result,ToastAndroid.SHORT);
                  })}         
          />
        <CustomButton
          text="扫码界面3,并且等待数据返回..." //CaptureActivity.class 0
          onPress={()=>NativeModules.ToastCustomAndroid.startActivityFromJSGetResult("com.xys.libzxing.zxing.activity.CaptureActivity",200,(msg) => {
                    ToastAndroid.show('JS界面:从Activity中传输过来的数据为:'+msg,ToastAndroid.SHORT);
                  },
                   (result) => {
                    ToastAndroid.show('JS界面:错误信息为:'+result,ToastAndroid.SHORT);
                  })}         
          />
      </View>
    );
  }
}
const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
  button: {
    margin: 5,
    backgroundColor: 'white',
    padding: 15,
    borderBottomWidth: StyleSheet.hairlineWidth,
    borderBottomColor: '#cdcdcd',
  },
});

export default fdxApp;